package com.zombie.effect;


import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.zombie.ResourceManager;
import com.zombie.logic.core.ZombieWorld;
import com.zombie.util.Utils;

public class DroppedShellEffect extends AbstractEffect
{
	
	public float angle;
	boolean up = true;
	float upSpeed = 64f;
	TextureRegion image = ResourceManager.getImage("shell");
	
	@Override
	public void update(int delta) {
		setLifeTime(getLifeTime()-delta);
		angle+= 512f/1000f*delta;
		position.x+= 10f/1000f*delta;
		position.y+= upSpeed/1000f*delta;
		upSpeed-= 0.1f*delta;
	}

//	@Override
//	public void draw(Graphics g) {
//		image.rotate(angle);
//		image.setAlpha(0.7f);
//		image.draw(position.x, position.y);
//		image.setRotation(0);
//		image.setAlpha(1);
//	}

	@Override
	public void remove() {
		ImageEffect eff = new ImageEffect();
		eff.setBounds(position.x, position.y, image.getRegionWidth(), image.getRegionHeight());
		eff.angle = angle;
		eff.image = image;
		ZombieWorld.addEffect(eff);
		ResourceManager.getSound("shell_"+Utils.rnd.nextInt(4)).play();
	}

	@Override
	public void draw(SpriteBatch batch, ShapeRenderer shapeBatch) {
		batch.draw(image, position.x, position.y, image.getRegionWidth()/2, image.getRegionHeight()/2, image.getRegionWidth(), image.getRegionHeight(), 1, 1, angle);
	}

}
